﻿using System;
using System.Collections.Generic;
using System.Text;
using Hkwl.WorldExpo.Merchant.Model;
using System.Collections;

namespace Hkwl.WorldExpo.Merchant.DataAccess.Impl.IBatisNet
{
    public class ProjectSqlMapDao : BaseSqlMapDao, IProjectDao
    {

        #region NxProject 对象

        public NxProject GetNxProjectById(int projectId)
        {
            return ExecuteQueryForObject<NxProject>("SelectNxProject", projectId);
        }

        public int GetNxProjectByName(string projectName, int merchantId)
        {
            Hashtable ht = new Hashtable();
            ht["ProjectName"] = projectName;
            ht["MerchantId"] = merchantId;

            return ExecuteQueryForObject<int>("GetNxProjectCountByName", ht);
        }

        public bool InsertNxProject(NxProject project)
        {
            object obj = ExecuteInsert("InsertNxProject", project);
            if ((int)obj > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool UpdateNxProject(NxProject project)
        {
            int ret = ExecuteUpdate("UpdateNxProject", project);
            if (ret > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool DeleteNxProject(int projectId)
        {
            int ret = ExecuteDelete("DeleteNxProject", projectId);
            if (ret > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public IList<NxProject> GetNxProjectCollection(int merchantId, int pageIndex, int pageSize, ref int count)
        {
            Hashtable ht = new Hashtable();
            ht["MerchantId"] = merchantId;

            count = ExecuteQueryForObject<int>("GetNxProjectCount", ht);
            return ExecuteQueryForList<NxProject>("GetNxProjectCollection", ht, (pageIndex - 1) * pageSize, pageSize);
        }

        public IList<NxProject> GetNxProjectCollectionByStatus(int merchantId, int status, int pageIndex, int pageSize, ref int count)
        {
            Hashtable ht = new Hashtable();
            ht["MerchantId"] = merchantId;
            ht["Status"] = status;

            count = ExecuteQueryForObject<int>("GetNxProjectCountByStatus", ht);
            return ExecuteQueryForList<NxProject>("GetNxProjectCollectionByStatus", ht, (pageIndex - 1) * pageSize, pageSize);
        }

        #endregion

        #region NxMms 对象

        public bool InsertNxMms(NxMms mms)
        {
            object obj = ExecuteInsert("InsertNxMms", mms);
            if ((int)obj > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool UpdateNxMms(NxMms mms)
        {
            int ret = ExecuteUpdate("UpdateNxMms", mms);
            if (ret > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool DeleteNxMms(int mmsId)
        {
            int ret = ExecuteDelete("DeleteNxMms", mmsId);
            if (ret > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public NxMms GetNxMmsById(int mmsId)
        {
            return ExecuteQueryForObject<NxMms>("SelecNxMms", mmsId);
        }

        public NxMms GetNxMmsByPage(int projectId, int mmsPage)
        {
            Hashtable ht = new Hashtable();
            ht["ProjectId"] = projectId;
            ht["MmsPage"] = mmsPage;
            return ExecuteQueryForObject<NxMms>("SelecNxMmsByPage", ht);
        }

        public IList<NxMms> GetNxMmsCollection(int projectId)
        {
            Hashtable ht = new Hashtable();
            ht["ProjectId"] = projectId;

            return ExecuteQueryForList<NxMms>("GetNxMmsCollection", ht);
        }

        #endregion
    }
}
